﻿// ServerUI.cpp : 定义应用程序的入口点。
//

#include "framework.h"
#include "ServerUI.h"
#include "WindowsMessage.h"

// 全局变量:

// 此代码模块中包含的函数的前向声明:
INT_PTR CALLBACK Server(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: 在此处放置代码。
    HWND hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_SERVER), NULL, Server);
    ShowWindow(hwnd, SW_SHOW);

    MSG msg;

    // 主消息循环:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int) msg.wParam;
}

// “关于”框的消息处理程序。
INT_PTR CALLBACK Server(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);

    switch (message)
    {
    case WM_INITDIALOG:
        return WindowsMessage::wm_initdialog(hDlg, message, wParam, lParam);
    case WM_COMMAND:
        return WindowsMessage::wm_command(hDlg, message, wParam, lParam);
    case WM_CLOSE:
        return WindowsMessage::wm_close(hDlg, message, wParam, lParam);
    case WM_SOCKET_NOTIFY:
        return WindowsMessage::wm_socket_notify(hDlg, message, wParam, lParam);
    }
    return (INT_PTR)FALSE;
}
